package com.yh.modules.data.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yh.common.exception.RRException;
import com.yh.modules.data.dao.MachineCheckDao;
import com.yh.modules.data.entity.MachineCheckEntity;
import com.yh.modules.data.service.MachineCheckService;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("machineCheckService")
public class MachineCheckServiceImpl extends ServiceImpl<MachineCheckDao, MachineCheckEntity> implements MachineCheckService {


	@Override
	public List<MachineCheckEntity> getMachineCheckListByMachineId(Integer machineId) {
		EntityWrapper<MachineCheckEntity> wrapper = new EntityWrapper<>();
		wrapper.eq("machine_id", machineId);
		wrapper.orderBy("sort", true);

		List<MachineCheckEntity> machineCheckEntityList = this.selectList(wrapper);

		if (CollUtil.isEmpty(machineCheckEntityList)) {
			throw new RRException("机器检测类型为空,请联系管理员");
		}

		return machineCheckEntityList;
	}
}
